<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>管理后台</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>
		<script src="js/config.js" type="application/javascript"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	</head>

	<body>
		<div class="x-body">
			<form class="layui-form" lay-filter="apiinfo">
				<div class="layui-form-item">
					<label class="layui-form-label">执行日期</label>
					<div class="layui-input-block">
						<input type="checkbox" name="周1" title="周一">
						<input type="checkbox" name="周2" title="周二">
						<input type="checkbox" name="周3" title="周三">
						<input type="checkbox" name="周4" title="周四">
						<input type="checkbox" name="周5" title="周五">
						<input type="checkbox" name="周6" title="周六">
						<input type="checkbox" name="周7" title="周日">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">时间选择</label>
					<div class="layui-input-inline" style="width: 60px;">
						<select name="xiaoshi" lay-verify="required" >
							<option value="">时</option>
							<option value="00">00</option>
							<option value="01">01</option>
							<option value="02">02</option>
							<option value="03">03</option>
							<option value="04">04</option>
							<option value="05">05</option>
							<option value="06">06</option>
							<option value="07">07</option>
							<option value="08">08</option>
							<option value="09">09</option>
							<option value="10">10</option>
							<option value="11">11</option>
							<option value="12">12</option>
							<option value="13">13</option>
							<option value="14">14</option>
							<option value="15">15</option>
							<option value="16">16</option>
							<option value="17">17</option>
							<option value="18">18</option>
							<option value="19">19</option>
							<option value="20">20</option>
							<option value="21">21</option>
							<option value="22">22</option>
							<option value="23">23</option>
						</select>
					</div>
					<div class="layui-input-inline" style="width: 60px;">
						<select name="fenzhong" lay-verify="required" >
							<option value="">分</option>
							<option value="00">00</option>
							<option value="01">01</option>
							<option value="02">02</option>
							<option value="03">03</option>
							<option value="04">04</option>
							<option value="05">05</option>
							<option value="06">06</option>
							<option value="07">07</option>
							<option value="08">08</option>
							<option value="09">09</option>
							<option value="10">10</option>
							<option value="11">11</option>
							<option value="12">12</option>
							<option value="13">13</option>
							<option value="14">14</option>
							<option value="15">15</option>
							<option value="16">16</option>
							<option value="17">17</option>
							<option value="18">18</option>
							<option value="19">19</option>
							<option value="20">20</option>
							<option value="21">21</option>
							<option value="22">22</option>
							<option value="23">23</option>
							<option value="24">24</option>
							<option value="25">25</option>
							<option value="26">26</option>
							<option value="27">27</option>
							<option value="28">28</option>
							<option value="29">29</option>
							<option value="30">30</option>
							<option value="31">31</option>
							<option value="32">32</option>
							<option value="33">33</option>
							<option value="34">34</option>
							<option value="35">35</option>
							<option value="36">36</option>
							<option value="37">37</option>
							<option value="38">38</option>
							<option value="39">39</option>
							<option value="40">40</option>
							<option value="41">41</option>
							<option value="42">42</option>
							<option value="43">43</option>
							<option value="44">44</option>
							<option value="45">45</option>
							<option value="46">46</option>
							<option value="47">47</option>
							<option value="48">48</option>
							<option value="49">49</option>
							<option value="50">50</option>
							<option value="51">51</option>
							<option value="52">52</option>
							<option value="53">53</option>
							<option value="54">54</option>
							<option value="55">55</option>
							<option value="56">56</option>
							<option value="57">57</option>
							<option value="58">58</option>
							<option value="59">59</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">定时器名称</label>
					<div class="layui-input-block">
						<input type="text" name="title" required lay-verify="required" placeholder="请输入测试集名称" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">选择测试集</label>
					<div class="layui-input-block">
						<select id="jobid" name="jobid" lay-filter="jobid">
						</select>
					</div>
				</div>
				<div class="layui-input-block" style="font-size: 12px; color: red;">*如不选择其中一个测试集，将执行项目全部用例</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>

			</form>
		</div>
		<script>
			layui.use(['layer', 'form'], function() {
				var layer = layui.layer;
				var form = layui.form;

				$.ajax({
					url: base_url + '/job/getlist/' + projectid,
					contentType: 'application/json; charset=utf-8',
					data: {},
					dataType: 'json',
					async: false,
					success: function(result) {
						if (result.code == '0') {
							var select = document.getElementById("jobid")
							select.options.add(new Option('', ''));
							$.each(result.data, function(n, value) {
								select.options.add(new Option(value.title, value.id));
							});
							form.render('select');
						} else {
							layer.msg(result.msg);
						}
					}
				});
				
				//监听提交
				form.on('submit(formDemo)', function(data) {
					$.ajax({
						url: base_url + '/timers/add',
						type: 'post',
						contentType: 'application/json; charset=utf-8',
						data: JSON.stringify(data.field),
						dataType: 'json',
						async: false,
						success: function(result) {
							if (result.code == '0') {
								layer.msg('添加成功');
								var index = parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							} else {
								layer.msg(result.msg);
							}
						}
					});
					return false;
				});

			});
		</script>
	</body>

</html>
